home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-21 / dvmacros.zip / DV_MISC.MAC < prev    next >
Text File  |  1993-03-03  |  6KB  |  210 lines

  1. .XLIST
  2. ; DV_MISC.MAC   1.0
  3. ; Daniel T. Travison Jr.  01/01/88
  4. ; misc macros for 32 bit data handling
  5. ; @PUSH, @POP, @MOVE
  6.  
  7. ; NOTES:
  8. ;     All TOPVIEW parameters are pushed on the stack
  9. ;     as 32 bit values.  These 3 macros are designed
  10. ;     to simplify this process by providing names for
  11. ;     common register pairs (see replacable paramaters)
  12. ;     as well as 32 bit data values.  I also included
  13. ;     entries for CR, LF and ESCAPE since I use these
  14. ;     in just about ALL desqview programs.
  15. ;     All three macros manipulate the data or registers
  16. ;     (push, pop, move) in the sequence that Topview
  17. ;     and Desqview expect.
  18.  
  19. ; USAGE:
  20. ;   > Simply place the macro at the top of your primary
  21. ;     source file and they will be available globally.
  22. ;   > All keywords ARE case sensitive and should always
  23. ;     be in upper case.
  24. ;   > The macros mimic those described in The Programmer's
  25. ;     Guide to Topview by Alan R. Miller.  I have not
  26. ;     found any case where the macros have not worked.
  27. ;     Problems that have arisen were related to my
  28. ;     programming errors and not the macro execution although
  29. ;     I was tempted several times to think otherwise.
  30. ;   > Error checking in the macros is limited.  All labels
  31. ;     used as parameters are asuumed to by defined as full
  32. ;     words.
  33.  
  34. CR        EQU    13
  35. LF        EQU    10
  36. ESCAPE    EQU    27
  37.  
  38. ; Replacable parameters:
  39. ; register pairs:
  40. ;    DXCX:    DX and CX
  41. ;    BXAX:    BX and AX
  42. ;    ESDI:    ES and DI
  43. ;    ESSI:    ES and SI
  44. ;    DSDI:    DS and DI
  45. ;    DSSI:    DS and SI
  46. ;
  47. ; Memory:
  48. ;    32 bit memory area defined as 2 consecutive words
  49. ;       ie: LABEL1  DW    2 DUP(0)
  50. ;                   @PUSH LABEL1
  51.  
  52. ; @PUSH ADDR1
  53. ;    ADDR1 = 32 bit address defined as 2 consecutive words
  54. ; or ADDR1 = register pair
  55. ;
  56. ; pushes 32 bit values onto the stack
  57. ; with the high 16 bits pushed 1st.
  58. ; argument is either a 16 bit memory
  59. ; address or a register pair symbol
  60.  
  61. @PUSH     MACRO  ADDR1
  62.           IFIDN  <ADDR1>,<DXCX>
  63.             PUSH   DX
  64.             PUSH   CX
  65.           ELSE
  66.           IFIDN  <ADDR1>,<BXAX>
  67.             PUSH   BX
  68.             PUSH   AX
  69.           ELSE
  70.           IFIDN  <ADDR1>,<ESDI>
  71.             PUSH   ES
  72.             PUSH   DI
  73.           ELSE
  74.           IFIDN  <ADDR1>,<ESSI>
  75.             PUSH   ES
  76.             PUSH   SI
  77.           ELSE
  78.           IFIDN  <ADDR1>,<DSDI>
  79.             PUSH   DS
  80.             PUSH   DI
  81.           ELSE
  82.           IFIDN  <ADDR1>,<DSSI>
  83.             PUSH   DS
  84.             PUSH   SI
  85.           ELSE
  86.             PUSH   ADDR1 + 2
  87.             PUSH   ADDR1
  88.             ENDIF
  89.             ENDIF
  90.             ENDIF
  91.             ENDIF
  92.             ENDIF
  93.             ENDIF
  94.           ENDM
  95.  
  96. ; @POP  ADDR1
  97. ;       ADDR1 = 16 bit address
  98. ;    or ADDR1 = register pair
  99. ;
  100. ; pops 32 bit values off the stack
  101. ; with the low 16 bits popped 1st.
  102. ; argument is either a 16 bit memory
  103. ; address or a register pair symbol
  104.  
  105. @POP      MACRO  ADDR1
  106.           IFIDN  <ADDR1>,<DXCX>
  107.             POP    CX
  108.             POP    DX
  109.           ELSE
  110.           IFIDN  <ADDR1>,<BXAX>
  111.             POP    AX
  112.             POP    BX
  113.           ELSE
  114.           IFIDN  <ADDR1>,<ESDI>
  115.             POP    DI
  116.             POP    ES
  117.           ELSE
  118.           IFIDN  <ADDR1>,<ESSI>
  119.             POP    SI
  120.             POP    ES
  121.           ELSE
  122.           IFIDN  <ADDR1>,<DSDI>
  123.             POP    DI
  124.             POP    DS
  125.           ELSE
  126.           IFIDN  <ADDR1>,<DSSI>
  127.             POP    SI
  128.             POP    DS
  129.           ELSE
  130.             POP    ADDR1
  131.             POP    ADDR1 + 2
  132.             ENDIF
  133.             ENDIF
  134.             ENDIF
  135.             ENDIF
  136.             ENDIF
  137.             ENDIF
  138.           ENDM
  139.  
  140. ; @MOVE ADDR1,ADDR2
  141. ;    ADDR1 = 16 bit address or register pair
  142. ;    ADDR2 = 16 bit address or register pair
  143. ;
  144. ; moves a 32 bit value:
  145. ; register pair to memory
  146. ; memory to a register pair
  147.  
  148. @MOVE     MACRO  ADDR1,ADDR2
  149.           IFIDN  <ADDR2>,<DXCX>
  150.             MOV    ADDR1,CX
  151.             MOV    ADDR1 + 2,DX
  152.           ELSE
  153.           IFIDN  <ADDR2>,<BXAX>
  154.             MOV    ADDR1,AX
  155.             MOV    ADDR1 + 2,BX
  156.           ELSE
  157.           IFIDN  <ADDR2>,<ESDI>
  158.             MOV    ADDR1,DI
  159.             MOV    ADDR1 + 2,ES
  160.           ELSE
  161.           IFIDN  <ADDR2>,<ESSI>
  162.             MOV    ADDR1,SI
  163.             MOV    ADDR1 + 2,ES
  164.           ELSE
  165.           IFIDN  <ADDR2>,<DSDI>
  166.             MOV    ADDR1,DI
  167.             MOV    ADDR1 + 2,DS
  168.           ELSE
  169.           IFIDN  <ADDR2>,<DSSI>
  170.             MOV    ADDR1,SI
  171.             MOV    ADDR1 + 2,DS
  172.           ELSE
  173.           IFIDN  <ADDR1>,<DXCX>
  174.             MOV    CX,[ADDR2]
  175.             MOV    DX,[ADDR2 + 2]
  176.           ELSE
  177.           IFIDN  <ADDR1>,<BXAX>
  178.             MOV    AX,[ADDR2]
  179.             MOV    BX,[ADDR2 + 2]
  180.           ELSE
  181.           IFIDN  <ADDR1>,<ESDI>
  182.             MOV    DI,[ADDR2]
  183.             MOV    ES,[ADDR2 + 2]
  184.           ELSE
  185.           IFIDN  <ADDR1>,<ESSI>
  186.             MOV    SI,[ADDR2]
  187.             MOV    ES,[ADDR2 + 2]
  188.           ELSE
  189.           IFIDN  <ADDR1>,<DSDI>
  190.             MOV    DI,[ADDR2]
  191.             MOV    DS,[ADDR2 + 2]
  192.           ELSE
  193.           IFIDN  <ADDR1>,<DSSI>
  194.             MOV    SI,[ADDR2]
  195.             MOV    DS,[ADDR2 + 2]
  196.             ENDIF
  197.             ENDIF
  198.             ENDIF
  199.             ENDIF
  200.             ENDIF
  201.             ENDIF
  202.             ENDIF
  203.             ENDIF
  204.             ENDIF
  205.             ENDIF
  206.             ENDIF
  207.             ENDIF
  208.           ENDM
  209. .LIST
  210.